//interface定义类的结构，但不实现类
interface PersonInterface {
  name: string;
  age: number;
  speak(n: number): void;
}

class Personchild implements PersonInterface {
  constructor(public name: string, public age: number) {}
  speak(n: number): void {
    for (let i = 0; i < n; i++) {
      console.log(`我的名字${this.name},今年${this.age}`);
    }
  }
}
const pc = new Personchild("张三", 18);
pc.speak(3); //我的名字张三,今年18 ---循环打印3次
